﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TodoApp.EntityFrameworkCore;
using TodoApp.Enum;
using TodoApp.LiveShopUsersDTO;
using TodoApp.UsersModel;
using Volo.Abp.Domain.Repositories;

namespace TodoApp
{
    /// <summary>
    ///  账号 
    /// </summary>
    public class UsersService : Volo.Abp.Application.Services.ApplicationService, IUsersService
    {

        private readonly IRepository<LiveShopUsers, int> db;

        public UsersService(IRepository<LiveShopUsers, int> _db )
        {
            db  = _db ;
        }

        public async Task<ShopStatus> CreateAsync(LiveShopUsersAddDTO Model)
        {
            var str = await db.InsertAsync(new LiveShopUsers
            {
                Names = Model.Names,
                Pass = Model.Pass,
                State = Model.State,
                RegisterTimes = Model.RegisterTimes
            });

            return ShopStatus.Succeed;
        }

        public async Task DeleteAsync(int id)
        {
            await db.DeleteAsync(id);
        }
        /// <summary>
        ///  显示 
        /// </summary>
        /// <returns></returns>
        public async Task<List<LiveShopUsersShowDTO>> GetCategorys()
        {
            var str = await db.GetListAsync();

            return str.Select(Model => new LiveShopUsersShowDTO
            {
                Id = Model.Id,
                Names = Model.Names,
                Pass = Model.Pass,
                State = Model.State,
                RegisterTimes = Model.RegisterTimes

            }).ToList();
        }
    }
}
